package com.xiaouyudeguang.common.context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class BeanContext {

    private static ApplicationContext context;

    public BeanContext(@Autowired ApplicationContext context) {
        BeanContext.context = context;
    }

    public static <T> T get(Class<T> cls) {
        return context.getBean(cls);
    }
}
